home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _1C105F1817E64D36A2CEB6AB3D4F2600 < prev    next >
Encoding:
Text File  |  2004-01-06  |  1.1 KB  |  33 lines

  1.  
  2.       #include "../CGVPMacro.csi"
  3.  
  4.       MainInput { uniform sampler2D bumpMap : texunit0,
  5.                   uniform sampler2D phongMap : texunit2,
  6.                     uniform float4 Specular }
  7.       DeclarationsScript
  8.       {
  9.         OUT_T0_T1_T2_T3
  10.         FOUT
  11.       }
  12.       CoreScript
  13.       {
  14.         // load the bump normal
  15.         float4 bumpNormal = 2*(tex2D(bumpMap, IN.Tex0.xy)-0.5);
  16.         // compute texCoord(NdotH, 0) and use it to look up NdotH^power in the power texture
  17.         // This should create a texm3x2tex instruction for ps_1_1 equivalent to the ps_1_1
  18.         // builtin tex2D_dp3x2 (which is not supported in any other profile):
  19.         //    float4 NdotL_NdotH = tex2D_dp3x2(specPowMap, IN.Tex2, bumpNormal);
  20.         float2 texCoord = float2(
  21.             dot(IN.Tex1.xyz, bumpNormal.xyz),
  22.             dot(IN.Tex2.xyz, bumpNormal.xyz));
  23.         float4 NdotL_NdotH = tex2D(phongMap, texCoord);
  24.  
  25.         // compute the specular color
  26.         float3 spec = (Specular.xyz * NdotL_NdotH.w) * 2;
  27.         
  28.         // finally add them all together
  29.         OUT.Color.xyz = spec.xyz;
  30.         OUT.Color.w = 1;
  31.       }
  32.  
  33.